package org.nicocube.airain.domain.client.util;

import java.util.LinkedList;
import java.util.List;

public class PublisherImpl implements Publisher {
	private final Publisher obj;
	private final List<Subscriber> subscribers;
	public PublisherImpl(Publisher obj) {
		this.obj = obj;
		subscribers = new LinkedList<Subscriber>();
	}

	@Override
	public void publish() {
		for (Subscriber subscriber : subscribers)
			subscriber.update(obj);
	}

	@Override
	public void subscribe(Subscriber subscriber) {
		subscribers.add(subscriber);
	}

	@Override
	public void unsubscribe(Subscriber subscriber) {
		subscribers.remove(subscriber);
	}

}
